import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:caose/caose.dart' show dip,sp;
import 'package:rebase_project/res/style.dart';

import 'Button.dart';

class HintDialog extends Dialog {
  const HintDialog(this.str,
      {this.cancelStr = "取消", this.allowStr = "确定", this.cancel, this.allow});

  final String str;
  final String cancelStr;
  final String allowStr;
  final VoidCallback cancel;
  final VoidCallback allow;

  @override
  Widget build(BuildContext context) {
    return Container(
        alignment: Alignment.center,
        child: Container(
          width: dip(300),
          decoration: BoxDecoration(
              color: Colors.white, borderRadius: radius_7),
          child: Column(
            mainAxisSize: MainAxisSize.min,
            children: <Widget>[
              Container(
                padding: EdgeInsets.symmetric(
                    horizontal: dip(15), vertical: dip(32)),
                child: Material(
                  color: Colors.transparent,
                  child: Text(
                    str,
                    style: TextStyle(
                      fontSize: sp(16),
                      color: Color(0xff303030),
                      fontWeight: FontWeight.w500,
                    ),
                  ),
                ),
              ),
              Divider(
                height: dip(1),
              ),
              Padding(
                padding: EdgeInsets.only(top: dip(12),bottom: dip(12)),
                child: Row(
                  children: <Widget>[
                    Expanded(
                      flex: cancelStr == null ? 0 : 1,
                      child: Button(
                        child: Text(cancelStr ?? "",
                            style: text_333_14),
                        onPressed: cancel == null
                            ? () {
                                Navigator.of(context, rootNavigator: true)
                                    .pop(false);
                              }
                            : cancel,
                      ),
                    ),
                    cancelStr == null || allowStr == null
                        ? Container()
                        : Container(
                            color: const Color(0x1F000000),
                            width: 0.4,
                            height: dip(39),
                          ),
                    Expanded(
                      flex: allowStr == null ? 0 : 1,
                      child: Button(
                        child: Text(allowStr ?? "",
                            style: text_333_14),
                        onPressed: allow == null
                            ? () {
                                Navigator.of(context, rootNavigator: true)
                                    .pop(true);
                              }
                            : allow,
                      ),
                    ),
                  ],
                ),
              )
            ],
          ),
        ));
  }
}
